package com.minova.demo.service.impl;

import com.minova.demo.entity.TzBasket;
import com.minova.demo.entity.TzOrder;
import com.minova.demo.entity.TzOrderItem;
import com.minova.demo.mapper.TzOrderMapper;
import com.minova.demo.service.ITzOrderItemService;
import com.minova.demo.service.ITzOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Calendar;
import java.util.Date;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 订单表 服务实现类
 * </p>
 *
 * @author linrongji
 * @since 2019-12-23
 */
@Service
public class TzOrderServiceImpl extends ServiceImpl<TzOrderMapper, TzOrder> implements ITzOrderService {

	@Autowired
	private TzOrderMapper orderMapper;
	
	

	

	@Override
	public String flow() {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
		String date = df.format(new Date());// new Date()为获取当前系统时间
		try {
			System.out.println(df.parse(date));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		Calendar cal = Calendar.getInstance();
		Random ran = new Random();
		String flow = cal.get(Calendar.YEAR) + "" + (cal.get(Calendar.MONTH) + 1) + cal.get(Calendar.DATE)
				+ cal.get(Calendar.HOUR_OF_DAY) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
		flow += (int) (Math.random() * (100000 - 10000) + 10000) + "";
		return orderMapper.selectByFlow(flow) != null ? flow() : flow;
	}

}
